<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品管理</title>
<%@include file="/WEB-INF/common/headeradmin.jsp" %>
</head>
<body class="easyui-layout">
	<div data-options="region:'west'" style="width:200px;" title="类别">
	<table id="categoryDataGrid"></table>
	</div>
	
	<div data-options="region:'center'" title="商品">
	<table id="productDataGrid"></table>
	</div>
	
	<script type="text/javascript">
	$("#productDataGrid").datagrid({
		url: root+"/admin/product/product/find",
		columns:[[
		   {title:"编号", field:"id", width:50, styler: function(){
			   return "height:50px;"
		   }},     
		   {title:"型号", field:"type", width:100},    
		   {title:"类别", field:"category", width:100},
		   {title:"类别编号", field:"c3id", width:40, hidden:true},
		   {title:"品牌", field:"brand", width:100},
		   {title:"价格", field:"price", width:40},
		   {title:"用途", field:"code", width:40, formatter: function(code){
			   if(code=='ziying') return "自营";
			   else if(code=="tongyong") return "通用";
			   else if(code="hangye") return "行业";
			   else return "";
		   }},
		   {title:"图片", field:"img", width:100, hidden:true},
		   {title:"详情", field:"detail", width:100, hidden:true}
		]],
		singleSelect: true,
		fit: true,
		fitColumns: true,
		border: false,
		pagination:true
	});
	
	$("#categoryDataGrid").treegrid({
		url: root+"/admin/product/category/find",
		columns:[[
		   {title:"编号", field:"id", width:20, hidden:true},     
		   {title:"名称", field:"text", width:100},    
		   {title:"属性", field:"attr", width:100, hidden:true}
		]],
		idField: "id",
		treeField: "text",
		dataPlain: true,
		fit: true,
		fitColumns: true,
		border: false,
		onSelect: function(node){
			console.log(node);
			if(node.id.length==6){
				$("#productDataGrid").datagrid("reload", {cid:node.id});
			}
		}
	});
	</script>
</body>
</html>